package com.everflourish.yeah100.act.test;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.everflourish.yeah100.R;

import java.util.List;

/**
 * Created by Administrator on 2016/12/9.
 */

public class TextAdpater extends RecyclerView.Adapter<TextAdpater.TestViewHolder> {


    private Context context;
    private List<TopicBean> datas;

    public TextAdpater(Context context, List<TopicBean> datas) {
        this.context = context;
        this.datas = datas;
    }


    @Override
    public TestViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_topic_new,parent,false);
        return new TestViewHolder(view);
    }

    @Override
    public void onBindViewHolder(TestViewHolder holder, int position) {
        TopicBean bean = datas.get(position);
        holder.topicname.setText(bean.getTopicName());
    }

    @Override
    public int getItemCount() {
        if (datas != null)
        return datas.size();
        return 0;
    }

    class TestViewHolder extends RecyclerView.ViewHolder {
        private TextView topicname;
        public TestViewHolder(View itemView) {
            super(itemView);

            topicname = (TextView) itemView.findViewById(R.id.topicname);
        }
    }
}
